(function() {
	Path.on("/__basename__.html", function(_current_location) {
		var queryString = _current_location.query;
		var id = queryString.get("id");
		// 获取会员卡信息
		coAjax.get(appConfig.card_factory.by_id + id, {
			bus_id: busInfo._id
		}, function(result) {
			if (!result.result) {
				myConfirm("卡信息无效或过期！");
				Path.jump("/main.html");
				return;
			};
			App.set("$Cache.membership.card", result.result);
		});
		// 用户添加会员卡
		App.set("$Event.membership.add_card_to_user", function() {
			if (!App.get("loginer")) {
				myConfirm("请先登陆或注册成为我们的会员，后来领取会员卡哦！！！(●'◡'●)ﾉ♥ ", function() {
					App.set("$Cache.sign_in.cb_url", "/membership.html?id=" + id);
					Path.jump("/sign_in.html");
					return;
				});
			} else {
				coAjax.post(appConfig.user.card_add_from_factory + id, function(result) {
					if (result.result) {
						App.concat("loginer.card_list", result.result);
						myConfirm("领卡成功，现在就去购物吧！");
						Path.jump("/main.html");
					};
				});
			};
		});
	});
}());